package com.app.lxx.pregnancyberth.utils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

import com.app.lxx.pregnancyberth.base.LocalBroadcastUtils;
import com.app.lxx.pregnancyberth.service.DataBus;
import com.app.lxx.pregnancyberth.ui.VoipP2PActivity;

/**
 * Created by Lxx on PregnancyBerth
 * 2020/9/22 14:47 星期二
 * Details:
 */
public class NetReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
//            new LocalBroadcastUtils(context).startLocalBroadcast(VoipP2PActivity.NETWORKCHANGE);
            DataBus.post("netChanged",new DataBus.Message(1));
        }
    }


    public interface OnNetConnect {
        void onNetConnect();

        void onNetDisConnect();
    }

    private OnNetConnect onNetConnect;

    public void setOnNetConnect(OnNetConnect onNetConnect) {
        this.onNetConnect = onNetConnect;
    }

}
